//package com.pro.config;
//
//import com.pro.service.JsClosureService;
//import com.pro.service.JsUnsealService;
//import com.pro.service.UserService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.text.SimpleDateFormat;
//
///**
// * @Author 祖铭泽
// * @Date 2021/12/16/0016
// * @description 侦听器
// */
//@Component
//public class SiYunConfig{
//
//    @Autowired
//    private JsClosureService jcs;
//
//    @Autowired
//    private UserService userService;
//
//    @Autowired
//    private JsUnsealService jsUnsealService;
//
//    //定时解封人员
//    @Scheduled(cron = "*/1 * * * * ?")
//    public void autoUnseal(){
//        System.out.println(123);
//        //获取所有封停记录
//        List<JsClosure> jsClosures = jcs.getJsClosures();
//        Long currentTime = new Date().getTime();
//        Long endDate = null;
//        for (JsClosure jsClosure : jsClosures) {
//            try {
//                //获取每条封停记录的毫秒值
//                endDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(jsClosure.getEndDate()).getTime();
//                //如果当前时间大于封停时间就自动解封
//                if(currentTime >= endDate){
//                    User user = new User();
//                    user.setUserId(jsClosure.getUserId());
//                    user.setStatus(1);
//                    //删除封停记录
//                    jcs.deleteClosureUser(jsClosure.getUserId());
//                    //更改用户帐号状态
//                    userService.updateUserStatus(user);
//                    JsUnseal jsUnseal = new JsUnseal();
//                    if(jsClosure.getType() == 2){
//                        jsUnseal.setType(2);
//                    }else if(jsClosure.getType() == 3){
//                        jsUnseal.setType(3);
//                    }
//                    jsUnseal.setUserCode(String.valueOf(jsClosure.getUserId()));
//                    jsUnseal.setDays(jsClosure.getDays());
//                    //添加解封记录
//                    jsUnsealService.addUnsealUser(jsUnseal);
//                }
//            } catch (ParseException e) {
//                e.printStackTrace();
//            }
//        }
//    }
//}
